#define _CRT_SECURE_NO_WARNINGS 1

class FoodRatings {
public:
    FoodRatings(vector<string>& foods, vector<string>& cuisines, vector<int>& ratings) {
        int n = foods.size();
        for (int i = 0; i < n; ++i)
        {
            _food_map[foods[i]] = { ratings[i], cuisines[i] };
            _rating_rank[cuisines[i]].insert({ -ratings[i], foods[i] });
        }
    }

    void changeRating(string food, int newRating) {
        int& rat = _food_map[food].first;
        string cus = _food_map[food].second;

        _rating_rank[cus].erase({ -rat, food });
        _rating_rank[cus].insert({ -newRating, food });

        rat = newRating;
    }

    string highestRated(string cuisine) {
        return (*_rating_rank[cuisine].begin()).second;
    }
private:
    unordered_map<string, pair<int, string>> _food_map;
    unordered_map<string, set<pair<int, string>>> _rating_rank;
};

/**
 * Your FoodRatings object will be instantiated and called as such:
 * FoodRatings* obj = new FoodRatings(foods, cuisines, ratings);
 * obj->changeRating(food,newRating);
 * string param_2 = obj->highestRated(cuisine);
 */